<include file="Public/head"/>
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css" />
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.js" type="text/javascript"></script>
<script src="http://img1.isou365.cn/paimai/yunying/js/city.js" type="text/javascript"></script>
<style>
    .xuanzhe ul li .menDao1{width:300px;}
    .xuanzhe ul li .menDao1 a{display:block;background:#cecece;color:#303030;float:left;width:36px; text-align:center;height:20px; line-height:20px; cursor:pointer;}
    .xuanzhe ul li .menDao1 .menHover{ background:#20ab4f;color:#fff;}

    .account{width:90%;float: left;}
    .accountCurrent{background-color: #33CCFF;color:#fff9f9;}
    .account ul{padding: 0px;}
    .account ul li{width: 36%;margin:0;padding:10px 0;border-radius: 5px;border:1px solid #E4E4E4;float: left;}
    .account ul>li:not(:first-child){margin-left: 4%;}
    .account ul li:hover{cursor:pointer;}
    .account ul li div{width: 100%;clear: both;}
    .account ul li span{height:25px;line-height:25px;display: block;width: auto;}
    .account ul li .span_right{text-align: right;width: 25%;}
</style>
<include file="Public/common_header"/>
<div class="mian">
    <include file="Public/sidebar" menu="cjgl.czqr"/>
    <div class="mianR">
        <h3 class="yonghu">
            <if condition="$status eq 2">
                流拍
                <elseif condition="$status eq 3" />
                确认成功
                <elseif condition="$status eq 4"/>
                磋商详情
                <elseif condition="$status eq 5"/>
                确认失败
            </if>
        </h3>
        <div class="chezhu-xinxi">
            <div class="xinxi-conter xinxi-conter1" style="background: none;border: none">
                <h4 class="order_no">拍卖单号：<b>{$detail.order_no}</b></h4>
            </div>
            <br/>
            <div class="xinxi-conter xinxi-conter1">
                <h4>车主信息</h4>
                <ul>
                    <li class="clearfix">
                            <em>车主类型</em><em class="name-text">{$detail.owner_type_name}</em>
                        <if condition="$detail.owner_type eq 1">
                            <em>车主姓名</em><em class="name-text">{$detail.seller_name}</em>
                        <else />
                            <em>公司名称</em><em class="name-text">{$detail.seller_name}</em>
                        </if>
                    </li>
                    <li class="clearfix">
                        <if condition="$detail.owner_type eq 1">
                            <em>联系电话</em><em class="name-text">{$detail.phone}</em>
                            <else />
                            <em>联系人姓名</em><em class="name-text">{$detail.contact_person}</em>
                            <em>联系电话</em><em class="name-text">{$detail.phone}</em>
                        </if>
                    </li>
                </ul>
            </div>
            <br/>
            <div class="xinxi-conter xinxi-conter1">
                <h4>车辆信息</h4>
                <ul>
                    <li class="clearfix">
                        <em>车型</em><em class="name-text">{$detail.model}</em>
                        <em>排放标准</em><em class="dian-hua">{$detail.emission}</em>
                    </li>

                    <li class="clearfix">
                        <em>初登日期</em><em class="name-text">{$detail.first_reg_date}</em>
                        <em>颜色</em><em class="dian-hua">{$detail.car_color}</em>
                    </li>
                    <li class="clearfix">
                        <em>表显里程</em><em class="name-text">{$detail.pointer_mileage}万公里</em>
                        <em>车况级别</em><em class="name-text">{$detail.composite_state}{$detail.accident_level}</em>
                    </li>
                    <li class="clearfix">
                        <em>车辆注册地</em><em class="name-text">{$detail.reg_city}</em>
                        <em>车牌号</em><em class="name-text">{$detail.plate_prefix}{$detail.plate_suffix}</em>
                    </li>
                    <li class="clearfix">
                        <em>过户限制</em><em class="name-text">{$transfer_type[$car_detail['transfer_limit']]}</em>
                        <em>渠道来源</em><em class="name-text">
                            <if condition="$car_detail.comefrom neq ''">
                            <?php if(empty($car_detail['comefrom_url'])):?>
                              <?php echo $show_from[$car_detail['comefrom']];?>
                            <?php else: ?>
                              <a href="{$car_detail.comefrom_url}" target="_blank" rel="noreferrer"><?php echo $show_from[$car_detail['comefrom']];?></a>
                            <?php endif;?>
                            <else/>
                              未知
                            </if>
                        </em>
                    </li>
                    <li class="clearfix">
                        <em>车架号</em><em class="name-text">{$detail.vin}</em>
                        <em>车辆所在地</em><em class="name-text">{$car_detail.location_area}</em>
                    </li>
                </ul>
            </div>
            <br/>
            <div class="xinxi-conter xinxi-conter1">
                <h4>拍卖信息</h4>
                <ul>
                    <li class="clearfix">
                        <em>竞拍结束时间</em><em class="name-text">{$detail.bidding_end_time}</em>
                        <em>第一名出价</em><em class="dian-hua">{$detail.format_best_price}元</em>
                    </li>

                    <if condition="(($detail.status eq 12) AND ($detail.owner_confirm_service_id gt 0) AND ($detail.fail_type eq 1)) OR (($detail.fail_type eq 2) OR ($detail.fail_type eq 6))">
                        <empty name="owner_remake_log">
                            <li class="clearfix">
                                <em>保留价</em>
                                <em class="name-text">{$detail.format_reserve_price}</em>
                                <em>过户限制</em>
                                <em class="name-text"><?php echo C('TRANSFER_LIMIT.'.$detail['transfer_limit']);?></em>
                            </li>
                            <else />
                            <li class="clearfix">
                                <em>原保留价</em>
                                <em class="name-text">{$detail.format_reserve_price}</em>
                                <em>原过户限制</em>
                                <em class="name-text"><?php echo C('TRANSFER_LIMIT.'.$owner_remake_log['last_transfer_limit']);?></em>
                            </li>
                            <li class="clearfix">
                                <em>现保留价</em>
                                <em class="name-text">
                                    <?=($owner_remake_log['reserve_price'] != $detail['reserve_price']) ? format_money($owner_remake_log['reserve_price']) : "不变";?>
                                </em>
                                <em>现过户限制</em>
                                <em class="name-text">
                                    <?=($owner_remake_log['transfer_limit'] != $owner_remake_log['last_transfer_limit']) ? C('TRANSFER_LIMIT.'.$owner_remake_log['transfer_limit']) : "不变";?>
                                </em>
                            </li>
                        </empty>
                        <else />
                        <li class="clearfix">
                            <em>保留价</em>
                            <em class="name-text">{$detail.format_reserve_price}元</em>
                            <em>过户限制</em>
                            <em class="name-text"><?php echo C('TRANSFER_LIMIT.'.$detail['transfer_limit']);?></em>
                        </li>
                    </if>

                    <?php if($detail['is_consult']==1):?>
                    <li class="clearfix">
                        <em>磋商成交价</em>
                        <em class="name-text">{:format_money($detail['success_price'] + $detail['company_subsidies'])}元</em>
                    <if condition="$detail.company_subsidies neq '0.00'" >
                        <em>公司补贴</em>
                        <em class="name-text">{$detail.company_subsidies}元</em>
                    </if>
                    </li>
                    <?php endif;?>
                </ul>
            </div>
            <br/>
            <if condition="$status eq 3">
                <div class="xinxi-conter xinxi-conter1">
                    <h4>预约信息</h4>
                    <ul>
                        <li class="clearfix">
                            <em>预约时间</em><em class="name-text">{$owner_info.sign_reserve_time}</em>
                            <em>服务方式</em><em class="dian-hua"><?=C('SERVICE_METHOD.'.$owner_info['sign_service_method']);?></em>
                        </li>
                        <li class="clearfix">
                        <if condition="$owner_info.sign_service_method eq 3">
                            <em>预约门店</em>
                            <em class="name-text">{$owner_info.sign_service_store}</em>
                            <elseif condition="$owner_info.sign_service_method eq 2" />
                            <em>预约门店</em>
                            <em class="name-text">{$owner_info.address}</em>
                            <else />
                            <em>预约地址</em>
                            <em class="name-text">未知</em>
                        </if>
                        </li>
                        <li class="clearfix">
                            <em>
                                <if condition="$status eq 3">
                                    确认备注
                                    <elseif condition="$status eq 4"/>
                                    磋商备注
                                </if>
                            </em>
                            <em class="name-text">{$owner_info.sign_reserve_remark}</em>
                        </li>
                    </ul>
                </div>
                <if condition="$detail['car_source'] eq 1 AND $detail['bank_account'] neq ''">
                    <br/>
                    <div class="xinxi-conter xinxi-conter1">
                        <h4>打款信息</h4>
                        <ul>
                            <li class="clearfix">
                                <em>开户银行</em>
                                <em class="name-text">{$detail.bank_name}</em>
                                <em>银行帐号</em>
                                <em class="dian-hua">{$detail.card_no}</em>
                            </li>
                            <li class="clearfix">
                                <em>账户名</em>
                                <em class="name-text" style="width:300px;">{$detail.account_name}</em>
                            </li>
                        </ul>
                    </div>
                </if>
            </if>

            <if condition="$status eq 4 ">
                <div class="xinxi-conter xinxi-conter1">
                    <h4>预约信息</h4>
                    <ul>
                        <li>
                            <em> 磋商备注</em>
                            <em class="name-text">{$owner_info.sign_reserve_remark}</em>
                        </li>
                    </ul>
                </div>
            </if>
        </div>

        <if condition="$status gt 1">
            <h3 class="yonghu">系统跟踪日志</h3>
            <div class="yonghuText">
                <ul>
                    <php>$confirm_logs = array('1'=>'同意卖车','2'=>'继续跟踪','3'=>'不卖','4'=>'磋商','5'=>'流拍')</php>
                    <volist name="trace_log" id="list" key="k">
                        <li class="{$k%2==0?'xitongBg':''} clearfix">
                            <em class="huShi">{$list.createtime}</em>
                            <em>客服</em><em>{$list.real_name}</em><em>{$confirm_logs[$list['result']]}</em>
                            <em class="huShi">{$list.remark}</em>
                        </li>
                    </volist>
                </ul>
            </div>
            <div class="yongBtn1">
                <input class="quxiao" type="submit" value="关闭" onclick="window.close();">
            </div>
        </if>

        <if condition="$detail['status'] eq 5 and $detail['is_consult'] eq 0">
            <h3 class="yonghu">请选择确认结果</h3>
            <div class="yuyue">
                <ul>
                    <li class="yuCurrent">同意卖车</li>
                    <li>磋商</li>
                    <li>重拍</li>
                    <li>继续跟踪</li>
                    <li>不卖</li>
                </ul>
            </div>

            <div class="listBox">
                <div class="yuList">
                    <div class="xuanzhe">
                        <ul>
                            <li class="clearfix">
                                <span>预约时间</span>
                                <input type="text" name="reserve_time" value="请选择预约时间" id="reserve_time" class="xiaci" readonly/>
                            </li>
                            <li class="clearfix">
                                <span>服务方式</span>
                                <span class="menDao">
                                    <a href="javascript:void(0);" onclick="$('#service_method').val(3);" class="menHover">到店</a>
                                    <a href="javascript:void(0);" onclick="$('#service_method').val(2);" >上门</a>
                                </span>
                                <input type="hidden" id="service_method" name="service_method"  value="3"/>
                            </li>
                            <li class="clearfix">
                                <span>预约地址</span>
                                <div class="store">
                                    <div class="detailed" style="display: block;">
                                        <select id="reserve_store" name="reserve_store" style="width:150px;">
                                            <option value="0">请选择门店</option>
                                            <?php foreach($stores as $key=>$vs):?>
                                            <option value="{$key}">{$vs}</option>
                                            <?php endforeach;?>
                                        </select>
                                    </div>
                                    <div class="detailed" style="display: none;">
                                        <script>var addr = new AddressCom('reserve');</script>
                                        <input type="text"  id="reserve_address" name="reserve_address" value="" placeholder="详细地址" class="xiangDi">
                                    </div>
                                </div>
                            </li>
                            <if condition="$detail.car_source eq 1">
                                <li class="clearfix">
                                    <span>打款账号</span>
                                    <input type="hidden" name="account_id" id="account_id" value="">
                                    <input type="hidden" name="bank_name" id="bank_name" value="">
                                    <input type="hidden" name="card_no" id="card_no" value="">
                                    <input type="hidden" name="account_name" id="account_name" value="">
                                    <div class="account">
                                        <ul>
                                            <volist name="fours_bank_account" id="fba" key="k">
                                                <li class="clearfix" data-id="{$fba.id}" data-bank-name="{$fba.bank_name}" data-card-no="{$fba.card_no}" data-account-name="{$fba.account_name}">
                                                    <if condition="$fours_bank_account_total gt 1">
                                                        <div>
                                                            <span class="span_right">打款帐号{$k}&nbsp;&nbsp;</span>
                                                        </div>
                                                    </if>
                                                    <div>
                                                        <span class="span_right">开户银行：</span>
                                                        <span>{$fba.bank_name}</span>
                                                    </div>
                                                    <div>
                                                        <span class="span_right">银行账号：</span>
                                                        <span>{$fba.card_no}</span>
                                                    </div>
                                                    <div>
                                                        <span class="span_right">账户名：</span>
                                                        <span>{$fba.account_name}</span>
                                                    </div>
                                                </li>
                                            </volist>
                                        </ul>
                                    </div>
                                </li>
                            </if>
                            <li class="clearfix remarks">
                                <span>备注</span><textarea name="reserve_remark"></textarea>
                            </li>
                        </ul>
                    </div>
                    <div class="yongBtn">
                        <input type="hidden" name="re_auction_type" value="{$re_auction_type}" />
                        <input type="hidden" name="first_money" value="{$first_money}" />
                        <?php if($detail['format_best_price']==0):?>
                            <input type="submit" disabled value="无人出价建议重拍" class="queding queding_hui " />
                        <?php else:?>
                            <input type="submit" value="确定" class="queding agree " />
                        <?php endif;?>
                        <input class="quxiao" type="submit" value="关闭" onclick="window.close();">
                    </div>
                </div>
                <div class="yuList" style="display:none;">
                    <div class="xuanzhe">
                        <ul>
                            <li class="clearfix remarks">
                                <span>备注</span><textarea name="reserve_remark1"></textarea>
                            </li>
                        </ul>
                    </div>
                    <div class="yongBtn">
                        <input type="hidden" name="re_auction_type" value="{$re_auction_type}" />
                        <input type="hidden" name="first_money" value="{$first_money}" />
                        <?php if($detail['format_best_price']==0):?>
                            <input type="submit" disabled value="无人出价建议重拍" class="queding queding_hui agree " />
                        <?php else:?>
                        <input type="submit" value="确定" class="queding consultation"/>
                        <?php endif;?>

                        <input class="quxiao" type="submit" value="关闭" onclick="window.close();">
                    </div>
                </div>

                <div class="yuList" style="display:none;">
                    <div class="xuanzhe1">
                        <ul>
                            <form name=reauctionform>
                                <li class="clearfix textCont">
                                    <span>保留价</span>
                                    <input id="reserve_price" type="text" name="reserve_price" value="{$detail.reserve_price}"/><em>元</em>
                                </li>
                                <li class="transfer">
                                    <input type="hidden" id="transfer_limit" value="{$detail.transfer_limit}">
                                    <span>过户限制</span>
                                    <?php foreach(C('TRANSFER_LIMIT') as $tk=>$val):?>
                                    <em class="<?php echo $detail['transfer_limit']==$tk ? 'active' : '' ;?>" data-id="{$tk}">{$val}</em>
                                    <?php endforeach;?>
                                </li>
                                <li class="reason clearfix">
                                    <span>备注</span>
                                    <textarea name="reauction_remark" cols="50"
                                              onKeyDown="textCounter(this.form.reauction_remark, this.form.remLen, 50);" onKeyUp="textCounter(this.form.reauction_remark, this.form.remLen, 50);"></textarea>
                                    <em></em>
                                </li>
                            </form>
                        </ul>
                    </div>
                    <div class="yongBtn">
                        <input type="button" value="确定" class="queding rephotograph"/>
                        <input class="quxiao" type="submit" value="关闭" onclick="window.close();">
                    </div>
                </div>

                <div class="yuList" style="display:none;">
                    <div class="xuanzhe1">
                        <ul>
                            <li class="genBtn1 clearfix trace">
                                <input type="hidden" id="trace_reason" value="">
                                <span class="gencuur">电话无人接听<input name="trace_reason" value="电话无人接听" type="checkbox"/></span>
                                <span class="gencuur">电话停机或关机<input name="trace_reason" value="电话停机或关机" type="checkbox"/></span>
                                <span class="gencuur">最近没时间<input name="trace_reason" value="最近没时间" type="checkbox"/></span>
                                <span class="gencuur">直接挂断电话<input name="trace_reason" value="直接挂断电话" type="checkbox"/></span>
                                <span class="gencuur">需要了解二手车拍卖<input name="trace_reason"  value="需要了解二手车拍卖" type="checkbox"/></span>
                            </li>
                            <li class="reason clearfix"><span>其他原因</span><textarea name="trace_other_reason"></textarea></li>
                            <li class="clearfix">
                                <span>下次跟踪时间</span>
                                <input type="text" name="next_trace_time" value="请选择下次跟踪时间" id="demoText9" class="xiaci" readonly/></li>
                        </ul>
                    </div>
                    <div class="yongBtn">
                        <input type="button" value="确定" class="queding continue_trace"/>
                        <input class="quxiao" type="submit" value="关闭" onclick="window.close();">
                    </div>
                </div>
                <div class="yuList" style="display:none;">
                    <div class="xuanzhe1">
                        <ul>
                            <li class="genBtn1 clearfix trace">
                                <input type="hidden" id="fail_reason" value="">
                                <span class="gencuur">车主要求重拍<input name="fail_reason" value="车主要求重拍" type="checkbox"/></span>
                                <span class="gencuur">不想卖了<input name="fail_reason" value="不想卖了" type="checkbox"/></span>
                                <span class="gencuur">价格不满意<input name="fail_reason" value="价格不满意" type="checkbox"/></span>
                                <span class="gencuur">无法过户<input name="fail_reason" value="无法过户" type="checkbox"/></span>
                                <span class="gencuur">车已出售<input name="fail_reason" value="车已出售" type="checkbox"/></span>
                                <span class="gencuur">对服务不满意<input name="fail_reason" value="对服务不满意"  type="checkbox"/></span>
                            </li>
                            <li class="reason clearfix">
                                <span>其他原因</span>
                                <textarea name="message"></textarea>
                                <em></em>
                            </li>
                        </ul>
                    </div>
                    <div class="yongBtn">
                        <input type="button" value="确定" class="queding disagree"/>
                        <input class="quxiao" type="submit" value="关闭" onclick="window.close();">
                    </div>
                </div>
            </div>
        </if>

    </div>
    <div class="clear"></div>
</div>
<script>
    $(document).ready(function () {
        //打款账号
        initAccount();
        $('.account ul li').on('click',function(){
            $(".account ul li").removeClass("accountCurrent");
            $(this).addClass("accountCurrent");
            $("#account_id").val($(this).attr('data-id'));
            $("#bank_name").val($(this).attr('data-bank-name'));
            $("#card_no").val($(this).attr('data-card-no'));
            $("#account_name").val($(this).attr('data-account-name'));
        });
        function initAccount(){
            var accountObj = $(".account ul li");
            var countAccount = accountObj.length;
            if(countAccount < 2){
                accountObj.addClass('accountCurrent');
                $("#account_id").val(accountObj.attr('data-id'));
                $("#bank_name").val(accountObj.attr('data-bank-name'));
                $("#card_no").val(accountObj.attr('data-card-no'));
                $("#account_name").val(accountObj.attr('data-account-name'));
            }
        }
        $("#reserve_time").ymdateplugin({
            showTimePanel: true,
            changeMonth: true,
            changeYear: true,
            gotoCurrent: true,
            ampm: true
        });

        $("#reserve_time1").ymdateplugin({
            showTimePanel: true,
            changeMonth: true,
            changeYear: true,
            gotoCurrent: true,
            ampm: true
        });

        $(".yuList ul .transfer em").click(function () {
            $(".yuList ul .transfer em").removeClass("active");
            $("#transfer_limit").val($(this).attr('data-id'));
            $(this).addClass("active");
        })
    });
    $(function () {
        $("#reserve_store").select2();
    });
    $(function () {
        $("#reserve_store1").select2();
    });
    addr.set_change(function (data) {
        allPrpos(data);
    });
    function allPrpos(obj) {
        var i = 0;
        for (var p in obj) {
            i++;
            if (typeof (obj[p]) == "function") {
                obj[p]();
            } else {
                switch (i) {
                    case 1:
                        $('input[name=reserve_province]').val(p);
                        break;
                    case 2:
                        $('input[name=reserve_city]').val(p);
                        break;
                    case 3:
                        $('input[name=reserve_area]').val(p);
                        break;
                    default:
                        console.log(i);
                        break;
                }
            }
        }
    }
    $('.consultation').click(function () {

        var order_id = '{$detail.order_id}';
        if (order_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var owner_id = '{$detail.owner_id}';
        if (owner_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }

        var reserve_remark = $.trim($('textarea[name=reserve_remark1]').val());
        confirm_alert('<div>您确认 磋商吗</div>', confirm_consultation);
        function confirm_consultation() {
            $('.determine').click(function () {
                colse_hide();
                consultation();
            });
        }
        function consultation() {
            var param = {
                'order_id': order_id,
                'owner_id': owner_id,
                'reserve_remark': reserve_remark
            };
            _myPost('/AuOrder/consultation',param)
        }
    });

    $('.rephotograph').on('click', function () {
        var order_id = '{$detail.order_id}';
        if (order_id == '') {
            shibai_alert('缺少拍单ID，请联系管理员');
            return;
        }
        var owner_id = '{$detail.owner_id}';
        if (owner_id == '') {
            shibai_alert('缺少车主ID，请联系管理员');
            return;
        }
        var reserve_price = $("#reserve_price").val();
        if (parseInt(reserve_price) == "NaN") {
            shibai_alert('保留价不能为空!');
            return;
        }
        var transfer_limit = $("#transfer_limit").val();
        var reauction_remark = $.trim($('textarea[name=reauction_remark]').val());
        confirm_alert('<div style="color:red">确定重拍？</div>', confirm);
        function confirm() {
            $('.determine').click(function () {
                colse_hide();
                re_auction();
            });
        }
        function re_auction() {
            var param = {
                'order_id': order_id,
                'owner_id': owner_id,
                'reserve_price': reserve_price,
                'last_transfer_limit': "{$detail.transfer_limit}",
                'transfer_limit': transfer_limit,
                'remark': encodeURIComponent(reauction_remark)
            };
            _myPost('/AuOrder/rephotograph',param)
        }
    });

    $('.agree').click(function () {

        var order_id = '{$detail.order_id}';
        if (order_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var owner_id = '{$detail.owner_id}';
        if (owner_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var success_price = '{$detail.best_price}';
        if (success_price == '' || success_price == '0') {
            shibai_alert('成交价格不能为空');
            return;
        }
        var reserve_time = $('#reserve_time').val();
        if (reserve_time == '请选择预约时间') {
            shibai_alert('请选择预约时间');
            return;
        }
        var car_srouce = '{$detail.car_source}';
        if(car_srouce == 1) {
            //判断是否选中打款帐号
            if (!$(".account ul li").hasClass('accountCurrent')) {
                shibai_alert('请选择打款账号');
                return;
            }
            ;
        }
        var service_method = $('#service_method').val();
        var addr_obj = addr.getarr();
        var reserve_province = (addr_obj.length > 0) ? addr_obj[0].code : '0';
        var reserve_city = (addr_obj.length > 0) ? addr_obj[1].code : '0';
        var reserve_area = (addr_obj.length > 0) ? addr_obj[2].code : '0';
        var reserve_address = $("#reserve_address").val();
        var reserve_store = $("#reserve_store").val();
        var reserve_remark = $.trim($('textarea[name=reserve_remark]').val());
        var account_id = $("#account_id").val();
        var bank_name = $("#bank_name").val();
        var card_no = $('#card_no').val();
        var account_name = $("#account_name").val();
        confirm_alert('<div style="color:red">您确定此辆车以' + success_price + '元成交吗？</div>', confirm);
        function confirm() {
            $('.determine').click(function () {
                colse_hide();
                agree();
            });
        }
        function agree() {
            var param = {
                'order_id': order_id,
                'owner_id': owner_id,
                'success_price': success_price,
                'reserve_time': reserve_time,
                'service_method': service_method,
                'reserve_province': reserve_province,
                'reserve_city': reserve_city,
                'reserve_area': reserve_area,
                'reserve_address': reserve_address,
                'reserve_store': reserve_store,
                'reserve_remark': reserve_remark,
                'account_id':account_id,
                'bank_name':bank_name,
                'card_no':card_no,
                'account_name':account_name
            };
            _myPost('/AuOrder/owner_agree',param)
        }

    });
    //---------------继续跟踪
    //点击继续跟踪的确认按钮
    $('.continue_trace').on('click', function () {

        var order_id = '{$detail.order_id}';
        if (order_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var owner_id = '{$detail.owner_id}';
        if (owner_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        $('input[name=trace_reason]').each(function (i) {
            if (this.checked == true) {
                $('#trace_reason').val(this.value);
                return false;
            } else {
                $('#trace_reason').val('');
            }
        });
        var trace_reason_selected = $('#trace_reason').val();
        var trace_reason_other = $.trim($('textarea[name=trace_other_reason]').val());
        var trace_reason = trace_reason_selected ? trace_reason_selected : trace_reason_other;

        if (trace_reason == '') {
            shibai_alert('请选择或输入下次跟踪原因');
            return;
        }
        var next_trace_time = $('input[name=next_trace_time]').val();
        if (next_trace_time == '请选择下次跟踪时间') {
            shibai_alert('请选择下次跟踪时间');
            return;
        }
        var param = {
            'order_id': order_id,
            'owner_id': owner_id,
            'next_trace_time': next_trace_time,
            'next_trace_remark': encodeURIComponent(trace_reason)
        };
        _myPost('/AuOrder/owner_continue_trace',param)
    });
    //---------------车主确认失败
    //点击确认按钮
    $('.disagree').on('click', function () {
        var order_id = '{$detail.order_id}';
        if (order_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var owner_id = '{$detail.owner_id}';
        if (owner_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        $('input[name=fail_reason]').each(function (i) {
            if (this.checked == true) {
                $('#fail_reason').val(this.value);
                return false;
            } else {
                $('#fail_reason').val('');
            }
        });
        var fail_reason_selected = $('#fail_reason').val();
        var fail_reason_other = $.trim($('textarea[name=message]').val());
        var fail_reason = fail_reason_selected ? fail_reason_selected : fail_reason_other;

        if (fail_reason == '') {
            shibai_alert('请选择或输入失败原因');
            return;
        }

        confirm_alert('<div style="color:red">确定不卖了吗？</div>', confirm);
        function confirm() {
            $('.determine').click(function () {
                colse_hide();
                disagree();
            });
        }
        function disagree() {
            var param = {
                'order_id': order_id,
                'owner_id': owner_id,
                'remark': encodeURIComponent(fail_reason)
            };
            _myPost('/AuOrder/owner_disagree',param)
        }
    });

    function _myPost(url,PostData){
        $(".yunBei").css("display","block").unbind('click')
        $(".loading").fadeIn();
        $.post(url, PostData, function (data) {
            if(data.code != 200){
                $(".loading").fadeOut();
                $(".yunBei").css("display","none")
                shibai_alert(data.msg);
                return false;
            }
            btn_alert("操作成功", 2000, function () {
                window.location.href = "/AuOrder/owner_confirm"
            });
        }, 'json')
    }

    $(".xuanzhe ul li .menDao1 a").click(function () {
        $(".xuanzhe ul li .menDao1 a").removeClass("menHover");
        $(this).addClass("menHover");
        var index = $(".xuanzhe ul li .menDao1 a").index(this);
        $(".xuanzhe ul li .store1 .detailed").eq(index).show().siblings().hide();
    });

    /**
     * 金钱数字转大写
     */
    function Arabia_to_Chinese(Num) {
        Num = Num + "";
        for (i = Num.length - 1; i >= 0; i--) {
            Num = Num.replace(",", "");
            Num = Num.replace(" ", "");
        }
        Num = Num.replace("￥", "")
        if (isNaN(Num)) {
            return;
        }
        part = String(Num).split(".");
        newchar = "";
        for (i = part[0].length - 1; i >= 0; i--) {
            if (part[0].length > 10) {
                return "";
            }
            tmpnewchar = ""
            perchar = part[0].charAt(i);
            switch (perchar) {
                case "0":
                    tmpnewchar = "零" + tmpnewchar;
                    break;
                case "1":
                    tmpnewchar = "壹" + tmpnewchar;
                    break;
                case "2":
                    tmpnewchar = "贰" + tmpnewchar;
                    break;
                case "3":
                    tmpnewchar = "叁" + tmpnewchar;
                    break;
                case "4":
                    tmpnewchar = "肆" + tmpnewchar;
                    break;
                case "5":
                    tmpnewchar = "伍" + tmpnewchar;
                    break;
                case "6":
                    tmpnewchar = "陆" + tmpnewchar;
                    break;
                case "7":
                    tmpnewchar = "柒" + tmpnewchar;
                    break;
                case "8":
                    tmpnewchar = "捌" + tmpnewchar;
                    break;
                case "9":
                    tmpnewchar = "玖" + tmpnewchar;
                    break;
            }
            switch (part[0].length - i - 1) {
                case 0:
                    tmpnewchar = tmpnewchar + "元";
                    break;
                case 1:
                    if (perchar != 0)
                        tmpnewchar = tmpnewchar + "拾";
                    break;
                case 2:
                    if (perchar != 0)
                        tmpnewchar = tmpnewchar + "佰";
                    break;
                case 3:
                    if (perchar != 0)
                        tmpnewchar = tmpnewchar + "仟";
                    break;
                case 4:
                    tmpnewchar = tmpnewchar + "万";
                    break;
                case 5:
                    if (perchar != 0)
                        tmpnewchar = tmpnewchar + "拾";
                    break;
                case 6:
                    if (perchar != 0)
                        tmpnewchar = tmpnewchar + "佰";
                    break;
                case 7:
                    if (perchar != 0)
                        tmpnewchar = tmpnewchar + "仟";
                    break;
                case 8:
                    tmpnewchar = tmpnewchar + "亿";
                    break;
                case 9:
                    tmpnewchar = tmpnewchar + "拾";
                    break;
            }
            newchar = tmpnewchar + newchar;
        }
        if (Num.indexOf(".") != -1) {
            if (part[1].length > 2) {

                part[1] = part[1].substr(0, 2)
            }
            for (i = 0; i < part[1].length; i++) { //for2
                tmpnewchar = ""
                perchar = part[1].charAt(i)
                switch (perchar) {
                    case "0":
                        tmpnewchar = "零" + tmpnewchar;
                        break;
                    case "1":
                        tmpnewchar = "壹" + tmpnewchar;
                        break;
                    case "2":
                        tmpnewchar = "贰" + tmpnewchar;
                        break;
                    case "3":
                        tmpnewchar = "叁" + tmpnewchar;
                        break;
                    case "4":
                        tmpnewchar = "肆" + tmpnewchar;
                        break;
                    case "5":
                        tmpnewchar = "伍" + tmpnewchar;
                        break;
                    case "6":
                        tmpnewchar = "陆" + tmpnewchar;
                        break;
                    case "7":
                        tmpnewchar = "柒" + tmpnewchar;
                        break;
                    case "8":
                        tmpnewchar = "捌" + tmpnewchar;
                        break;
                    case "9":
                        tmpnewchar = "玖" + tmpnewchar;
                        break;
                }
                if (i == 0)
                    tmpnewchar = tmpnewchar + "角";
                if (i == 1)
                    tmpnewchar = tmpnewchar + "分";
                newchar = newchar + tmpnewchar;
            }
        }
        while (newchar.search("零零") != - 1){
            newchar = newchar.replace("零零", "零");
            newchar = newchar.replace("亿零万", "亿");
            newchar = newchar.replace("零亿", "亿");
            newchar = newchar.replace("亿万", "亿");
            newchar = newchar.replace("零万", "万");
            newchar = newchar.replace("零元", "元");
            newchar = newchar.replace("零角", "");
            newchar = newchar.replace("零分", "");
        }
        if (newchar.charAt(newchar.length - 1) == "元" || newchar.charAt(newchar.length - 1) == "角"){
            newchar = newchar + "整";
        }
        return newchar;
    }
</script>
<include file="Public/foot" />